package thin4ca

import scala.collection.immutable.Map;
import scala.io._;

class Template(contentz: String) {

  def content() = contentz

  def populate(data: Map[String, Any]) = {
    var contentWithData = contentz;
    data.elements.foreach(entry => 
      contentWithData = contentWithData.replaceAll("\\$" + entry._1, entry._2.asInstanceOf[String]))
    contentWithData
  }

  def analyze() =
    for (t <- List.fromString(contentz, ' ') if t.startsWith("$")) yield t.substring(1,t.length)
}
